var app = getApp()
Page({
        data: {
                maxTextLen:10
        },
        onLoad: function (options) {
                wx.setNavigationBarTitle({
                        title: '你好'
                })
        },

// 登录
login_data(e) {
        console.log(e.detail.value)
        wx.request({
                url: 'http://localhost:3000/user_login',
                method: "POST",
                data: {
                        data:e.detail.value
                },
                success: (res) => {
                        console.log(res.data)
                        app.globalData.data = res.data
                       if(res.data[0].id == e.detail.value.user_id && res.data[0].pwd == e.detail.value.user_pwd  ){
                        wx.switchTab({
                                url: '../../../../pages/home/home'
                        })
                        }else if(res.data == "找不到"){
                                console.log("登录失败")
                                wx.showToast({
                                        title: '账号或密码有误，请重新输入',
                                        icon: 'none',
                                        duration: 1000,
                                })
                        }
                },
                fail: (err) =>{
                        console.log(err)
                }
        })
},





// 忘记密码
lost_paw() {
        console.log("忘记密码")
        wx.navigateTo({
                url: '../login/lost_pwd/lost_pwd',
                // url: '/login/login/pages/login/lost_pwd/lost_pwd',
                success: function (res) {
                        console.log("成功")
                        console.log(res)
                },
                fail: (err) => {
                        console.log("错误")
                        console.log(err)
                }
        })
},
// 注册
sign_in() {
        console.log("注册")
        wx.navigateTo({
                url: '../login/sign_in/sign_in',
        })
},
wx_login() {
        console.log("213")
        wx.login({
                success: function (res) {
                        if (res.code) {
                                console.log(res.code)
                        } else {
                                console.log('获取用户登录态失败！' + res.errMsg)
                        }
                }
        });
}
})